import cv2

filename = '/Users/wangxi/Desktop/ML_Study/openCV/第一章计算机视觉引论/lena.jpg'

img = cv2.imread(filename)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

cv2.imshow('souce image',img)
cv2.imshow('gray',gray)
cv2.waitKey()

hsv = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)

cv2.imshow('Hue',hsv[:,:,0])
cv2.imshow('Saturation',hsv[:,:,1])
cv2.imshow('Value',hsv[:,:,2])
cv2.waitKey()

cv2.imshow('Blue',img[:,:,0])
cv2.imshow('Green',img[:,:,1])
cv2.imshow('Red',img[:,:,2])

cv2.waitKey()
cv2.destroyAllWindows()